package common

import (
	"image"
	"image/draw"
)

/*
 * CreateIcon
 * @Desc	获得Icon
 * @Param	bgImg image.Image	背景图
 * @Param	content image.Image	中间图
 */
func CreateCenter(bgImg image.Image, center image.Image) (rgba *image.RGBA, err error) {
	//得到背景图的大小
	b := bgImg.Bounds()
	cb := center.Bounds()

	//居中设置图片到背景图中
	offset := image.Pt((b.Max.X-cb.Max.X)/2, (b.Max.Y-cb.Max.Y)/2)
	rgba = image.NewRGBA(b)
	draw.Draw(rgba, b, bgImg, image.Point{X: 0, Y: 0}, draw.Src)
	draw.Draw(rgba, cb.Add(offset), center, image.Point{X: 0, Y: 0}, draw.Over)
	return
}
